package ru.isu.imei.adm.dao;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
import org.hibernate.validator.Pattern;

@Entity
public class Login {
    private static final int USERNAME_MIN_SIZE = 5;
    private static final int PASSWORD_MIN_SIZE = 5;
    private static final int USERNAME_MAX_SIZE = 50;
    private static final int PASSWORD_MAX_SIZE = 15;

    @Id
    @GeneratedValue
    private Long id;

    @NotNull
    @Pattern(regex = "[a-zA-Z0-9\\.@]*", message = "username can contains letters, digits, periods, at")
    @Length(min = USERNAME_MIN_SIZE, max = USERNAME_MAX_SIZE)
    @Column(unique = true)
	private String username;

    @NotNull
    @Length(min = PASSWORD_MIN_SIZE, max = PASSWORD_MAX_SIZE)
	private String password;

    @Column(name = "is_enable")
	private Boolean isEnabled;

    @Column(name = "registration_date")
    private Date registrationDate;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Boolean getIsEnabled() {
		return isEnabled;
	}

	public void setIsEnabled(Boolean isEnabled) {
		this.isEnabled = isEnabled;
	}

	public Date getRegistrationDate() {
		return (Date) registrationDate.clone();
	}

	public void setRegistrationDate(Date registrationDate) {
		this.registrationDate = (Date) registrationDate.clone();
	}

}
